package com.zzw.design.observer;

import java.util.Observable;
import java.util.Observer;

public class Reader implements Observer{

	private String name;
	
	public Reader(String name){
		this.name = name;
	}
	
	public String getName() {
		return name;
	}
	
	public void subscribe(String wirterName){
        WriterManger.getInstance().getWriter(wirterName).addObserver(this);
	}
	
	public void unsubscribe(String writerName){
		WriterManger.getInstance().getWriter(writerName).deleteObserver(this);
	}
	
	public void update(Observable o, Object arg) {
		if (o instanceof Writer) {
            Writer writer = (Writer) o;
            System.out.println(name+"֪��" + writer.getName() + "���������顶" + writer.getLastNovel() + "������Ҫȥ����");
        }
	}
}
